How to group by property in an array of objs in javascript